import time

from selenium.webdriver.common.by import By
from src2.Base.Base import Base
class Page(Base):

    # 断言文本     体验DeepSeek模型专线版
    dy1_loc = (By.CLASS_NAME,'deepseek-title')
    def dy1(self):
        return self.text(self.dy1_loc)

    # 输入
    shur_loc = (By.ID,'query')
    def shur(self):
        self.send_keys(self.shur_loc,'软件测试自动化')
    # 点击搜索
    sousuo_loc = (By.ID,'stb')
    def sousuo(self):
        self.click(self.sousuo_loc)

    #第一页搜索结果     /html/body/div[3]/div[2]/div[1]/div[3]/div[1]/div[1]/div/h4/a/span
    jieguo1_loc = (By.XPATH,'/html/body/div[3]/div[2]/div[1]/div[3]')
    def jieguo1(self):
        self.find_elements(self.jieguo1_loc)
    # 点击第二页
    dj2_loc = (By.XPATH,'//*[@id="sogou_page_2"]')
    def dj2(self):
        self.click(self.dj2_loc)

    # 搜索结果     /html/body/div[3]/div[2]/div[1]/div[2]/div/div[1]/h3/a
    jieguo2_loc = (By.XPATH, '/html/body/div[3]/div[2]/div[1]/div[2]')
    def jieguo2(self):
        self.find_elements(self.jieguo2_loc)



    def test_sougou(self):
        self.open_url('https://www.sogou.com/')
        self.implicitly_wait(5)
        print('断言页面元素:',self.dy1())
        assert '体验DeepSeek模型专线版' == self.dy1()
        self.implicitly_wait(3)
        self.shur()
        self.sousuo()
        time.sleep(3)
        self.jieguo1()
        time.sleep(3)
        self.dj2()
        time.sleep(5)
        self.refresh()
        self.jieguo2()
        time.sleep(3)






